#handle single error
print("test 1")
try:
    file = open("test.txt", "rb")
except IOError as e:
    print("An IOError occurred. {}".format(e.args[-1]))

#handle multi error
print("test 2")
try:
    file = open('test.txt', 'rb')
except EOFError as e:
    print("An EOF error occurred.")
    raise e
except IOError as e:
    print("An error occurred.")
    raise e

print("test 3")
try:
    file = open('test.txt', 'rb')
except Exception:
    print("handle and error")
    raise

print("test 4")
try:
    file = open('test.txt', 'rb')
except IOError as e:
    print("An IOError occurred. {}".format(e.args[-1]))
finally:
    print("This would be printed whether or not an exception occurred!")

print("test5")
try:
    print("i am sure no exception is going to occur!")
except Exception:
    print("exception")
else:
    print("this would only run if no exception occurs")
finally:
    print("this would be printed in every case.")